package old.apiday04;

import java.util.*;

public class ListDemo {
    public static void main(String[] args) {
        List <String> list=new ArrayList<>();
        list.add("one");
        list.add("two");
        list.add("three");
        list.add("four");
        list.add("five");
        System.out.println("list"+list);
        String e= list.get(3);
        System.out.println(e);

        for (int i = 0; i <list.size() ; i++) {
            System.out.println(list.get(i));
        }//普通for循环

        for (String s:list){
            System.out.println(s);
        }//增强for循环

        Iterator<String>it=list.iterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }//迭代器循环
        System.out.println(".........................");
        list.set(2,"six");
        Collections.reverse(list);//反转集合元素
        System.out.println(list);
        list.add(3,"three");
        System.out.println(list);
        list.remove(2);
        System.out.println(list);


    }
}
